package fudan.se.project.controller.account.admin;


import fudan.se.project.controller.request.OnlyIdPropertyRequest;
import fudan.se.project.service.advanced.account.admin.AdminActionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.Min;


@Slf4j
@RestController
@RequestMapping("/admin")
public class AdminActionController {

    private final AdminActionService adminActionService;


    public AdminActionController(AdminActionService adminActionService) {
        this.adminActionService = adminActionService;
    }

    @GetMapping("/conferences")
    public ResponseEntity<?> conferences(
            @RequestParam  int state,
            @RequestParam @Min(0) int page,
            @RequestParam @Min(-1) int itemsPerPage
    ) {
        log.debug("admin get conferences: state" + state + ", page" + page + ", itemsPerPage" + itemsPerPage);


        return adminActionService.getConferences(state, page, itemsPerPage);
    }

    @PostMapping("/conference/confirm")
    public ResponseEntity<?> confirmConference(@Validated @RequestBody OnlyIdPropertyRequest request) {

        return adminActionService.confirmConference(request);
    }

    @PostMapping("/conference/reject")
    public ResponseEntity<?> rejectConference(@Validated @RequestBody OnlyIdPropertyRequest request) {

        return adminActionService.rejectConference(request);
    }


}
